#pragma once
#include "zMatrixBase.hpp"
#include "zMatrix.hpp"
#include <Math/Vector.hpp>
#include <Math/Matrix.hpp>

namespace zzz{
//////////////////////////////////////////////
//Dress to cast value
template<typename TO, typename FROM, class Major>
class zMatrixCastR : public zMatrixBaseR<TO,Major>
{
public:
  explicit zMatrixCastR(const zMatrixBaseR<FROM,Major> &mat):Mat_(mat),zMatrixBaseR<TO,Major>(mat.rows_,mat.cols_){}
  const TO operator()(zuint r, zuint c) const
  {
    CheckRange(r, c);
    return static_cast<TO>(Mat_(r,c));
  }
  using zMatrixBaseR<TO,Major>::operator();
private:
  const zMatrixBaseR<FROM,Major> &Mat_;
};
template<typename TO, typename FROM, class Major>
const zMatrixCastR<TO,FROM,Major> Cast(const zMatrixBaseR<FROM,Major> &mat)
{return zMatrixCastR<TO,FROM,Major>(mat);}

}

